<template>
  <div class="login_container">
    <!--登录区域-->
    <div class="login_box">
      <div class="head_box">
        <img class="head_img" src="../assets/img/logo/qing.png">
      </div>
      <div class="login-box">
        <el-form :model="numberValidateForm" ref="numberValidateForm" label-width="0px" class="login-form">
          <el-form-item prop="username" :rules="[{ required: true, message: '用户名不能为空'}]" >
            <el-input type="username" v-model.number="numberValidateForm.username" autocomplete="off" prefix-icon="el-icon-user"></el-input>
          </el-form-item>
          <el-form-item prop="password" :rules="[{ required: true, message: '密码不能为空'},{min:6,max:12,message:'长度在6-12个字符'}]" >
            <el-input type="password" v-model.number="numberValidateForm.password" autocomplete="off" prefix-icon="el-icon-lock" show-password="false"></el-input>
          </el-form-item>
          <el-form-item prop="verify" :rules="[{ required: true, message: '验证码不能为空'}]" >
            <el-input type="verify" v-model.number="numberValidateForm.verify" autocomplete="off" prefix-icon="el-icon-message"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="submitForm('numberValidateForm')">登录</el-button>
            <el-button @click="resetForm('numberValidateForm')">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Login',
  data() {
    return {
      numberValidateForm: {
        username: '',
        password: '',
        verify: '',
      }
    };
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$router.push('./main')
          // alert('submit!');
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
  }
};
</script>

<style scoped>
.login_container{
  width: 100%;
  height: 100%;
  text-align: center;
  background-color: #2B845E;
}
.login_box {
  width: 450px;
  height: 350px;
  background-color: azure;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 10px;
  /*box-shadow: 5px 5px 10px #d8dbe6;*/
}
  .head_box{
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background-color: azure;
    box-shadow: 5px 5px 10px #d8dbe6;
    margin: -70px auto;
  }
  .head_img{
    width: 90%;
    height: 90%;
    margin: 5% auto;
    border-radius: 50%;
  }
  .login-box{
    width: 70%;
    margin-left: 15%;
    position: absolute;
    top: 100px;
  }
  .login-form{
    width: 100%;
  }
</style>
